\section{network::rs\_\-socket Class Reference}
\label{classnetwork_1_1rs__socket}\index{network::rs_socket@{network::rs\_\-socket}}
This class represents a socket over the rs-232-interface.  


{\tt \#include $<$rs\_\-socket.h$>$}

Inheritance diagram for network::rs\_\-socket::\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2cm]{classnetwork_1_1rs__socket}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
\bf{rs\_\-socket} (const string \&file)
\begin{CompactList}\small\item\em \doxyref{rs\_\-socket}{p.}{classnetwork_1_1rs__socket} creates a new serial-socket over the appropriate device \item\end{CompactList}\item 
virtual \bf{$\sim$rs\_\-socket} ()\label{classnetwork_1_1rs__socket_348eb72b9ff4220a106224ee97e55362}

\item 
virtual void \bf{send} (const string \&str)
\begin{CompactList}\small\item\em send sends a string over the socket. \item\end{CompactList}\item 
virtual string \bf{recv} ()
\begin{CompactList}\small\item\em recv receives a string over the socket. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
This class represents a socket over the rs-232-interface. 



Definition at line 46 of file rs\_\-socket.h.

\subsection{Constructor \& Destructor Documentation}
\index{network::rs_socket@{network::rs\_\-socket}!rs_socket@{rs\_\-socket}}
\index{rs_socket@{rs\_\-socket}!network::rs_socket@{network::rs\_\-socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}network::rs\_\-socket::rs\_\-socket (const string \& {\em file})}\label{classnetwork_1_1rs__socket_cca11ec7f6274c6c66b54d05fee3e697}


\doxyref{rs\_\-socket}{p.}{classnetwork_1_1rs__socket} creates a new serial-socket over the appropriate device 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em file}]is the device, from which the socket should be created. (e.g. /dev/tty\-S0) \end{description}
\end{Desc}


Definition at line 4 of file rs\_\-socket.cpp.

\begin{Code}\begin{verbatim}5 {
6         termios newtio;
7         _fd = open(file.c_str(), O_RDWR | O_NOCTTY);
8         if(_fd == -1) {
9                 throw network::socket_exception("Error, couldn't open" + file);
10         }
11 
12         bzero(&newtio, sizeof(newtio));
13 
14         /*
15          * BAUDRATE = set bps
16          * CS8 = 8n1
17          * CLOCAL = local connection, no modem control
18          * CREAD = enable receiving characters
19          */
20         newtio.c_cflag = BAUDRATE | CS8 | CLOCAL | CREAD;
21         newtio.c_cflag &= ~CRTSCTS;      // disable hardware flow control
22         /*
23          * IGNPAR = ignore bytes with parity errors
24          * ICRNL = map CR to NL
25          */
26         newtio.c_iflag = IGNPAR | ICRNL;
27         newtio.c_oflag = 0;
28         /*
29          * ICANON = enable cononical input
30          */
31         newtio.c_lflag = 0;
32 
33         /* 
34          * initialize all control characters 
35          * default values can be found in /usr/include/termios.h, and are given
36          * in the comments, but we don't need them here
37          */
38         newtio.c_cc[VINTR]    = 0; /* Ctrl-c */ 
39         newtio.c_cc[VQUIT]    = 0; /* Ctrl-\ */
40         newtio.c_cc[VERASE]   = 0; /* del */
41         newtio.c_cc[VKILL]    = 0; /* @ */
42         newtio.c_cc[VEOF]     = 4; /* Ctrl-d */
43         newtio.c_cc[VTIME]    = 0; /* inter-character timer unused */
44         newtio.c_cc[VMIN]     = 1; /* blocking read until 1 character arrives */
45         newtio.c_cc[VSWTC]    = 0; /* '\0' */
46         newtio.c_cc[VSTART]   = 0; /* Ctrl-q */ 
47         newtio.c_cc[VSTOP]    = 0; /* Ctrl-s */
48         newtio.c_cc[VSUSP]    = 0; /* Ctrl-z */
49         newtio.c_cc[VEOL]     = 0; /* '\0' */
50         newtio.c_cc[VREPRINT] = 0; /* Ctrl-r */
51         newtio.c_cc[VDISCARD] = 0; /* Ctrl-u */
52         newtio.c_cc[VWERASE]  = 0; /* Ctrl-w */
53         newtio.c_cc[VLNEXT]   = 0; /* Ctrl-v */
54         newtio.c_cc[VEOL2]    = 0; /* '\0' */
55         
56         /*
57          * clean modem line
58          */
59         tcflush(_fd, TCIFLUSH);
60         tcsetattr(_fd, TCSANOW, &newtio);
61 }
\end{verbatim}\end{Code}




\subsection{Member Function Documentation}
\index{network::rs_socket@{network::rs\_\-socket}!recv@{recv}}
\index{recv@{recv}!network::rs_socket@{network::rs\_\-socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}string network::rs\_\-socket::recv ()\hspace{0.3cm}{\tt  [virtual]}}\label{classnetwork_1_1rs__socket_d77b7334c0c5c878afb2163948413d3c}


recv receives a string over the socket. 

\begin{Desc}
\item[Returns:]a string is returned by the serial socket \end{Desc}


Implements \bf{network::i\_\-socket} \doxyref{p.}{classnetwork_1_1i__socket_611208a9f52680378427b1fff5e22ed9}.

Definition at line 72 of file rs\_\-socket.cpp.

\begin{Code}\begin{verbatim}73 {
74         char buf[100];
75         int res = read(_fd, buf, 100);
76         buf[res] = 0;
77         string str(buf);
78         return str;
79 }
\end{verbatim}\end{Code}


\index{network::rs_socket@{network::rs\_\-socket}!send@{send}}
\index{send@{send}!network::rs_socket@{network::rs\_\-socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void network::rs\_\-socket::send (const string \& {\em str})\hspace{0.3cm}{\tt  [virtual]}}\label{classnetwork_1_1rs__socket_b61afed0e8f4be5e77d613c3c5685063}


send sends a string over the socket. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em str}]is the string which should be sended \end{description}
\end{Desc}


Implements \bf{network::i\_\-socket} \doxyref{p.}{classnetwork_1_1i__socket_8cb41213426b4744601dacba0ddae3fc}.

Definition at line 67 of file rs\_\-socket.cpp.

\begin{Code}\begin{verbatim}68 {
69         write(_fd, str.c_str(), str.size());
70 }
\end{verbatim}\end{Code}




The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
network/rs\_\-socket.h\item 
network/rs\_\-socket.cpp\end{CompactItemize}
